package com.joven.shelltest.utils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author joven_wong
 * 2022/9/15 18:16
 */
public class SubUtils {

    private final static String REGEX = "/";

    public static String subPath(String s) {
        String s3;
        if (s.startsWith(REGEX)) {
            s3 = s.substring(1);
        } else {
            s3 = s;
        }
        String[] result = s3.split(REGEX);
        List<String> l1 = Arrays.stream(result).filter(s1 -> !s1.contains(".sh")).collect(Collectors.toList());
        StringBuffer sb = new StringBuffer();
        for (String s2 : l1) {
            sb.append(REGEX).append(s2);
        }
        return sb.toString();
    }

}
